package com.fuxi.cloud.desreport.render.utils;

/**
 * ExcelColumn
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
public class ExcelColumn {
    public ExcelColumn() {
    }

    public static void main(String[] args) {
        String var1 = "AA";
        int var2 = a(var1, var1.length());
        System.out.println("'" + var1 + "' column index of " + var2);
        byte var3 = 26;
        var1 = a(Integer.valueOf(var3));
        System.out.println(var3 + " column in excel of " + var1);
        var1 = "B";
        var2 = a(var1, var1.length());
        System.out.println("'" + var1 + "' column index of " + var2);
        var3 = 66;
        var1 = a(Integer.valueOf(var3));
        System.out.println(var3 + " column in excel of " + var1);
    }

    public static int a(String var0, int var1) {
        boolean var2 = false;
        int var3 = 0;

        for(int var4 = 0; var4 < var1; ++var4) {
            char var5 = var0.charAt(var1 - var4 - 1);
            int var6 = var5 - 65 + 1;
            var6 = (int)((double)var6 * Math.pow(26.0D, (double)var4));
            var3 += var6;
        }

        return var3;
    }

    public static String a(Integer var0) {
        if (var0 <= 0) {
            return null;
        } else {
            String var1 = "";
            var0 = var0 - 1;

            do {
                if (var1.length() > 0) {
                    var0 = var0 - 1;
                }

                var1 = (char)(var0 % 26 + 65) + var1;
                var0 = (var0 - var0 % 26) / 26;
            } while(var0 > 0);

            return var1;
        }
    }

    public int a(String var1) {
        int var2 = var1.length();
        boolean var3 = false;
        int var4 = 0;

        for(int var5 = 0; var5 < var2; ++var5) {
            char var6 = var1.charAt(var2 - var5 - 1);
            int var7 = var6 - 65 + 1;
            var7 = (int)((double)var7 * Math.pow(26.0D, (double)var5));
            var4 += var7;
        }

        return var4;
    }

    private String a(int var1) {
        if (var1 <= 0) {
            return null;
        } else {
            String var2 = "";
            --var1;

            do {
                if (var2.length() > 0) {
                    --var1;
                }

                var2 = (char)(var1 % 26 + 65) + var2;
                var1 = (var1 - var1 % 26) / 26;
            } while(var1 > 0);

            return var2;
        }
    }
}

